<?php

namespace app\admin\controller;

use app\common\controller\AdminBaseController;

class ArticleCategoryController extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize();
        $this->server = model('server.article_category');
        /*

        su - www -s /bin/sh -c "git pull origin master"
        */
    }

    public function getArticleCategoryTreeAllOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getTreeAll();

        return $responseData;
    }

    public function saveArticleCategoryAddOp()
    {
        $requestData = validateRequestParam('article_category', 'saveAdd');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveAdd($requestData);

        return $responseData;
    }

    public function getArticleCategoryRowOp()
    {
        $requestData = validateRequestParam('article_category', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getRow($requestData);

        return $responseData;
    }

    public function saveArticleCategoryEditOp()
    {
        $requestData = validateRequestParam('article_category', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveEdit($requestData);

        return $responseData;
    }

    public function saveArticleCategoryDelOp()
    {
        $requestData = validateRequestParam('article_category', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->saveDel($requestData);

        return $responseData;
    }

    public function getArticleCategoryTreeOp()
    {
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getTree();

        return $responseData;
    }
}
